<header class="main-header">
    <a href="../../index2.html" class="logo" style="background-color: #222d32;color: #fff;border-right: none;border-bottom: 1px solid grey;">
        <span class="logo-mini">wolf</span>
        <span class="logo-lg"><b>互联网商户平台项目</b></span>
    </a>
    <!-- Header Navbar: style can be found in header.less -->
    <nav class="navbar navbar-static-top" >
        <!-- Sidebar toggle button-->
        <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </a>

        <div class="navbar-custom-menu">
            <ul class="nav navbar-nav">
                <li class="dropdown messages-menu">
                    <a href="#" id="unread">
                        <i class="fa fa-envelope-o"></i>
                    </a>
                </li>
                <li class="dropdown tasks-menu">
                    <a href="#" >
                        <i class="fa fa-flag-o"></i>
                    </a>
                </li>
                <li class="dropdown notifications-menu">
                    <a href="#" >
                        <i class="fa fa-bell-o"></i>
                    </a>
                </li>
                <li>
                    <a href="#"  class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-gears"></i></a>
                    <ul class="dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close" style="min-width: 100px;">
                        <li>
                            <a href="#">
                                <i class="fa fa-cog" ></i>
                                个人设置
                            </a>
                        </li>
                        <li class="divider"></li>
                        <li>
                            <a href="#" id="updatePassword">
                                <i class=" fa fa-user"></i>
                                修改密码
                            </a>
                        </li>
                        <li class="divider"></li>
                        <li>
                            <a href="/userLogout">
                                <i class="fa fa-power-off"></i>
                                注销
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </nav>
</header>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">修改密码</h4>
            </div>
            <div class="modal-body">
                <form id="updatePass" action="/employee/updatePassword" method="post">
                    <input type="hidden" name="id" value="${USER_IN_SESSION.id}">
                    <div class="form-group">
                        <label for="exampleInputEmail1">密码:</label>
                        <input type="text" class="form-control" name="password" id="password" placeholder="请输入密码">
                    </div>
                    <div class="form-group">
                        <label for="exampleInputPassword1">再次输入密码:</label>
                        <input type="text" name="repassword" class="form-control" id="repassword" placeholder="请再次输入密码">
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="submit" class="btn btn-primary">确认修改</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    $('#updatePassword').click(function () {
        $('#myModal').modal('show');

    });


    $("#updatePass").bootstrapValidator({
        feedbackIcons: { //图标
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields:{ //配置要验证的字段
            password:{
                validators:{
                    notEmpty:{ //不能为空
                        message:"密码必填" //错误时的提示信息
                    },
                }
            },
            repassword:{
                validators:{
                    notEmpty:{ //不能为空
                        message:"密码必填" //错误时的提示信息
                    },
                    identical: {//两个字段的值必须相同
                        field: 'password',
                        message: '两次输入的密码必须相同'
                    },
                }
            }

        }
    }).on('success.form.bv', function() { //表单所有数据验证通过后执行里面的代码
        //提交异步表单
        $("#updatePass").ajaxForm(function (data) {
            if (data.success) {
                Swal.fire(
                    data.msg,
                    'That thing is still around?',
                    'success'
                ).then((result) => {
                    if (result.value) {
                        window.location="/employee/list"
                    }
                })
            }else {
                Swal.fire(
                    data.msg,
                    '',
                    'error'
                ).then((result) => {
                    if (result.value) {

                    }
                })
            }

        })
    });
    $.get('/notice/getUnread',function (data) {
        $('#unread').append('<span class="icon-bar">未读'+data.data+'</span>')
    })
</script>